
$(document).ready(function () {
    // Generate a simple captcha
    function randomNumber(min, max) {
        return Math.floor(Math.random() * (max - min + 1) + min);
    };
    $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));

    $('#defaultForm').bootstrapValidator({
//        live: 'disabled',
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {
                message: '用户名无效',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空'
                    },
                    stringLength: {
                        max: 20,
                        message: '用户名不超过20个字符'
                    }
                }
            },
            password: {
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    regexp: {
                        regexp: /[0-9a-zA-Z]/,
                        message: '密码只能由字母、数字组成'
                    },
                    stringLength: {
                        min: 6,
                        message: '密码不能小于6为'
                    }
                }
            },
            mechanism: {
                validators: {
                    stringLength: {
                        max: 50,
                        message: '机构名称不能超过50个字符'
                    }
                }
            },
            Localarea: {
                validators: {
                    stringLength: {
                        max: 50,
                        message: '所在地区不能超过50个字符'
                    }
                }
            },
            Contact: {
                validators: {
                    notEmpty: {
                        message: '联系人不能为空'
                    },
                    stringLength: {
                        max: 20,
                        message: '联系人不能超过20个字符'
                    }
                }
            },
            phone: {
                validators: {
                    notEmpty: {
                        message: '联系电话不能为空'
                    },
                    stringLength: {
                        max: 20,
                        message: '电话不能超过20个字符'
                    }
                }
            },
            Enable: {
                validators: {
                    notEmpty: {
                        message: '请选择状态'
                    }
                }
            },
           Createtime: {
                validators: {
                    notEmpty:{
                        message: '请选择开始时间'
                    }
                }
            },
           Endtime: {
                validators: {
                    notEmpty:{
                        message: '请选择终止时间'
                    }
                }
            }
        }
    });
});
